package mutilthread;

/**
 * Created with IntelliJ IDEA.
 * Description: 观察 interrupt 如何唤醒 wait
 * Interrupt 本来目的是，让线程终止，唤醒阻塞只是 “终止线程的一个环节”
 * User: Li_yizYa
 * Date: 2025—04—01
 * Time: 16:44
 */
public class Demo18 {
    private static Object Locker = new Object();

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            synchronized (Locker) {
                System.out.println("wait 之前");
                try {
                    Locker.wait();
                } catch (InterruptedException e) {
                    System.out.println("wait 之后");
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();

        Thread.sleep(1000);

        t.interrupt();
    }
}
